//
//  ADNaviManagerProtocol.h
//  BDNaviDemo
//
//  Created by AnDa-Y on 2019/8/2.
//  Copyright © 2019 AnDa-Y. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AMapNaviKit/AMapNaviKit.h>
#import "ADNaviDriveView.h"
#import "ADNaviRouteInfo.h"

@class ADLocationModel;

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM (NSInteger, ADNavigationStatus) {
    ADNavigationStatusNotStart,
    ADNavigationStatusToOrigin,
    ADNavigationStatusToDestination,
    ADNavigationStatusDispatching,
};

typedef NS_ENUM (NSInteger, ADNavigationErrorType) {
    ADNavigationErrorTypeCalculateRoute,
    ADNavigationErrorTypeStartNavigation
};

typedef NS_ENUM (NSInteger, ADNavigationRouteType) {
    ADNavigationRouteTypeAfterCalculate,
    ADNavigationRouteTypeAfterStartNavi,
    ADNavigationRouteTypeRouteUpdate
};

typedef NS_ENUM (NSInteger, ADNavigationEventType) {
    ADNavigationEventTypeArrived,
    ADNavigationEventTypeNeedRecalculate,
    ADNavigationEventTypeGpsSignal
};

@protocol ADNavigationManagerDelegate;

@protocol ADNaviManagerProtocol <NSObject>

@property (assign, nonatomic) ADNavigationStatus navigationStatus;
@property (weak, nonatomic) id<ADNavigationManagerDelegate> delegate;
@property (assign, nonatomic) BOOL isSimulateNav;

- (void)setupStrategy:(NSInteger)strategy;
- (void)addDriveView:(ADNaviDriveView *)driveView;
- (void)removeDriveView:(ADNaviDriveView *)driveView;

- (void)mapDidLoadOnView:(UIView *)aView;
- (void)mapWillAppearOnView:(UIView *)aView;
- (void)mapDidAppearOnView:(UIView *)aView;
- (void)mapWillDisappearOnView:(UIView *)aView;

- (void)startNavigationFrom:(CLLocationCoordinate2D)aLoc toB:(CLLocationCoordinate2D)bLoc;
- (BOOL)startFullScreenNavigation;
- (void)stopNavigation;

- (void)adjustShowLocation;
- (void)adjustShowTrafficLayer;

- (void)destroySelf;

@end

#define kNaviPointAllowNotUpdateTime 60 //允许导航不更新的时间，单位s
#define kNaviPointBadAccuracyValue 100 //精度差的判断标准，小于等于该值的为精度好
#define kAllowBadAccuracyPointCount 10 //允许精度差的点的个数，超过会重新计算路径并开启导航
#define kBadAccuracyPointRetryCount 2 //允许重新计算路径的次数，超过会建议使用定位点

@protocol ADNavigationManagerDelegate <NSObject>

@optional

- (void)navigationManager:(id<ADNaviManagerProtocol>)manager
          updateRouteInfo:(ADNaviRouteInfo *)routeInfo
                     type:(ADNavigationRouteType)routeType;

- (void)navigationManager:(id<ADNaviManagerProtocol>)manager
               occurError:(NSError *)error
                     type:(ADNavigationErrorType)errorType;

///导航位置更新
- (void)navigationManager:(id<ADNaviManagerProtocol>)manager
           updateLocation:(nullable ADLocationModel *)naviLocation;

///导航期间的事件
- (void)navigationManager:(id<ADNaviManagerProtocol>)manager
               occurEvent:(ADNavigationEventType)evenType context:(id)context;

///是否需要播报语音
- (BOOL)navigationManagerNeedBroadcastVoice:(id<ADNaviManagerProtocol>)manager;

@end
NS_ASSUME_NONNULL_END
